test: migrate stats/base/dists/beta/variance to ULP-based assertions - #14837
Draft
kgryte wants to merge 1 commit into
Draft
test: migrate stats/base/dists/beta/variance to ULP-based assertions#14837kgryte wants to merge 1 commit into
stats/base/dists/beta/variance to ULP-based assertions#14837kgryte wants to merge 1 commit into
Conversation
Ref: #11352 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: skipped - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
stats/base/dists/beta/variancefrom relative-tolerance assertions (delta <= tol, withdelta = abs( y - expected[ i ] )andtol = 1.0 * EPS * abs( expected[ i ] )) to ULP-difference assertions using@stdlib/assert/is-almost-same-value.test/test.jsandtest/test.native.js.NaNinput,alpha <= 0,beta <= 0), and drops the now-unusedabsandEPSrequires.ULP bound
test/test.jstest/test.native.js0is the measured minimum, and is the tightest bound possible. Starting fromN = 64and tightening agentically,N = 0still holds for every one of the 1000 entries intest/fixtures/julia/data.json: both implementations reproduce every expected value exactly, soisAlmostSameValue( actual, expected[ i ], 0 )(same-value equality) is satisfied throughout.This is expected for this package rather than surprising.
variance( alpha, beta )is computed as(alpha*beta) / (apb*apb*(apb+1))withapb = alpha + beta, i.e. a short chain of exactly-rounded multiplications, one addition, and one division, with no cancellation and no series expansion. The previous1.0 * EPSrelative tolerance was already effectively an exactness check for this fixture set.Both
test/test.jsandtest/test.native.jswere run twice at the finalNto confirm deterministic passing (1014 assertions each, all passing on both runs, no FMA/architecture-dependent variation). The native add-on was built locally for this package so thattest/test.native.jsexecutes rather than skips. As an additional check against FMA contraction,src/main.cwas compiled and evaluated over the full fixture set under-O0,-O2,-O3 -ffp-contract=off, and-O3 -ffp-contract=fast; all four configurations reproduce all 1000 expected values exactly, so the0ULP bound is not dependent on compiler flags.Linting is clean: both files pass
etc/eslint/.eslintrc.tests.jswith no errors, and the repository's pre-commit lint stages (JavaScript test lint, filename lint, commit-message lint) pass. The only files changed are the two test files.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
The
editorconfigpre-commit stage could not run in this environment because downloading theeditorconfig-checkerbinary is blocked by the sandbox network policy. Both files were instead verified manually against.editorconfig(LF endings, UTF-8, tab indentation, no trailing whitespace, final newline present); all other pre-commit lint stages ran normally.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code: the assistant mechanically converted the tolerance-based assertions to
isAlmostSameValue, agentically searched for the minimum ULP bound over the full fixture set, built the native add-on and cross-checked the C implementation under several compiler flag sets, verified determinism across two full runs of each test file, and ran the local lint and test suites before submitting.@stdlib-js/reviewers
Generated by Claude Code